﻿using Models.Sys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zo.Models;

namespace Logics.Sys
{
    public class AdminRoleLogic:BaseLogic
    {
        /// <summary>
        /// 根据管理员id获取角色列表
        /// </summary>
        /// <param name="adminId"></param>
        /// <returns></returns>
        public List<Sys_Role> GetRolesByAdminId(int adminId)
        {
           IQueryable<int> rr= db.Sys_AdminRole.Where(c => c.AdminId.Equals(adminId)).Select(c=>c.RoleId);
            if(rr.Count()==0)
            {
                return null;
            }
            var result = db.Sys_Role.Where(c => rr.Contains(c.Id)).ToList();
            return result;
        }

    }
}
